Skip to content

Improve clarity of next('route') usage in Route Handlers section #2034

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Open
wants to merge 1 commit into
base: gh-pages
Choose a base branch
from

Conversation

yelishgiri
Copy link

@yelishgiri yelishgiri commented Aug 8, 2025

Description:
This PR adds a concrete example demonstrating the use of next('route') in the “Route handlers” section of the Express routing documentation.

Currently, the docs mention next('route') but don’t show a simple, self-contained example, which could make it unclear for new users. This change:

Adds a GET /user/:id example that uses next('route') to skip to the next matching route.
Includes a short bullet-point explanation of the behavior for two different request paths (/user/5 and /user/0).

Before:
The section explains next('route') but doesn’t show a minimal code sample demonstrating it in action.

After:
The section now contains:

app.get('/user/:id', (req, res, next) => {
  if (req.params.id === '0') {
    return next('route')
  }
  res.send(`User ${req.params.id}`)
})

app.get('/user/:id', (req, res) => {
  res.send('Special handler for user ID 0')
})

In this example:
GET /user/5 → handled by first route → sends "User 5"
GET /user/0 → first route calls next('route'), skipping to the next matching /user/:id route

Why this change improves the docs:

Makes the next('route') behavior obvious without requiring guesswork.
Matches the style and tone of existing Express documentation.
Adds a practical example to complement the textual explanation.

@yelishgiri yelishgiri requested a review from a team as a code owner August 8, 2025 06:51
Copy link

netlify bot commented Aug 8, 2025

Deploy Preview for expressjscom-preview ready!

Name Link
🔨 Latest commit 6112bbd
🔍 Latest deploy log https://app.netlify.com/projects/expressjscom-preview/deploys/68959e57484dcf00085de804
😎 Deploy Preview https://deploy-preview-2034--expressjscom-preview.netlify.app
📱 Preview on mobile
Toggle QR Code...

QR Code

Use your smartphone camera to open QR code link.

To edit notification comments on pull requests, go to your Netlify project configuration.

Copy link
Contributor

github-actions bot commented Aug 8, 2025

🚦 Lighthouse Results (Mobile & Desktop)

URL Device Perf A11y Best Practices
/ mobile 🔴 58 🟢 100 🟢 96
/en/blog/posts.html mobile 🔴 72 🟢 96 🟢 96
/en/5x/api.html mobile 🔴 67 🟢 95 🟢 96
/ desktop 🟢 95 🟢 100 🟢 96
/en/blog/posts.html desktop 🟢 93 🟢 96 🟢 93
/en/5x/api.html desktop 🟢 94 🟢 95 🟢 96

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

1 participant